package unit4.part9;

public class ReWriteTest {
    public static void main(String[] args) {
        RWSuper rwSuper = new RWSuper();
        rwSuper.tell();
        System.out.println(rwSuper.cal(4));

        System.out.println("-----------------------------");

        RWSon rwSon = new RWSon();
        rwSon.tell();
        System.out.println(rwSon.cal(4));
    }
}

class RWSuper {

    void tell() {
        System.out.println("父类tell方法");
    }

    String cal(int i) {
        return i + " * 10";
    }

    RWSuper() {
        System.out.println("父类构造");
    }
}

class RWSon extends RWSuper {
    void tell() {// 覆盖式重写
        System.out.println("子类tell方法");
    }

    String cal(int i) {// 扩展式重写
        return super.cal(i) + " + 2000";
    }

    RWSon() {// 默认就会调用父类构造函数
        System.out.println("子类构造");
    }
}